<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<html>
<head>
    <title>江苏高考志愿填报系统</title>
</head>
<link rel="stylesheet" href="css/style.css" >
<link href='css/jquery.tableui.css'  rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="css/bootstrap.min.css" >
<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-nav.js"></script>
<script type="text/javascript" src="js/jquery.tableui.js"></script>
<body style="background-color: #3ea751">
    <%--头部div--%>
    <div class="box">
    <ul class="f-nav" id='f-nav'>
    <a onclick="javascript:Check();"><li>首页</li></a>
    <a href="/school_search"><li>高校信息查询</li></a>
    <a onclick="javascript:Foo();"><li>考生志愿填报</li></a>
    <a href="/show_vol"><li>志愿填报查询</li></a>
    <div class='sideline'></div>
    </ul>
</div>
<!-- 高校检索条件div -->
<div style="margin: 30px 200px; width:74%; background-color: #8fcafe; height: 100px;">
<div style="position: relative; top: 20px; width:100%;" align="center">
    <form method="post" id="sub_form">
    <span style="font-family: 'Microsoft YaHei';font-size: 18px;color: #a94442">批次：</span><select id="batch" name="batch_id">
    <option value="0">- -请选择批次- -</option>
    <option value="101" name="first">第一批次</option>
    <option value="102" name="second">第二批次</option>
    </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-family: 'Microsoft YaHei';font-size: 18px;color: #a94442">院校：</span><select id="school" name="sch_id">
    <option value="0">- - 请选择院校 - -</option>
    </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-family: 'Microsoft YaHei';font-size: 18px;color: #a94442">专业：</span><select id="major" name="major_id">
    <option value="0">- - 请选择专业 - -</option>
    </select>&nbsp;&nbsp;<br>
    <div align="center">
    <input type="button" class="btn btn-warning" value="检&nbsp;索" onclick="sub_data()" style="margin-top: 10px; cursor: pointer">
    </div>
    </form>
    </div>
</div>
<!-- 检索结果div -->
<div style="margin: 30px 200px; width: 74%;">
<div style=" height: 50px; margin: 0 auto; background-color: #dddddd">
<span style="position: relative; left: 30px; top: 10px; color: #025aa5; font-size: 18px; font-family: 'Microsoft YaHei';font-weight: bold">检索结果</span>
    <br><br>
    <div id="result_div">
        <table class="table_solid" border="0" cellspacing="0">
            <tr style="text-align: center; color: blue;height: 35px">
                <td>高校编号</td>
                <td width="180">高校名称</td>
                <td>高校所在地</td>
                <td>所属批次</td>
                <td>上一年学校录取分</td>
                <td>专业名称</td>
                <td>上一年专业录取分</td>
            </tr>
            <c:forEach step="1" begin="1" end="10">
            <tr style="height: 35px">
                <c:forEach step="1" begin="1" end="7">
                    <td></td>
                </c:forEach>
            </tr>
            </c:forEach>
        </table>
    </div>
</div>
</div>
</body>
<script>
$('#f-nav').tooltip({
    default: 2,       // 默认为空  --  选中默认值
    width: '200',     // 限制宽度
    height: '100',
    type: 'slideMove',  // 必填, 选择内容
    success: function(ret){

    }   //初始化回调
});
function Check(){
    var user = ${loginUser.stu_id};
    if(user == null || user == ''){
        $(window).attr('location','/init');
    }
    $(window).attr('location','/main');
}
function Foo(){
    var mydate = new Date();
    var str = "" + mydate.getFullYear() + "-";
    str += (mydate.getMonth()+1) + "-";
    str += mydate.getDate();
    var now = new Date(str);
    var fixtime = new Date("2018-06-28");
    if(now>fixtime){
        swal("志愿填报时间已过");
        return false;
    }
    if(${empty loginUser}){
        $(window).attr('location','/init');
    }
    $.post("check_vol",{"stu_id":${loginUser.stu_id}},function(data){
        if(data == "false"){
            swal("您已经填写过志愿信息！");
        }
        else{
            $(window).attr('location','/tian_bao');
        }
    })
}
function sub_data() {
    $.post("/search_result",$('#sub_form').serialize(),function (data) {
        var array = data.split("|");
        var str = '';
        for(var i=0;i<array.length-1;i++){
            var array2 = array[i].split("^");
            str += "<tr style=\"text-align: center; height: 35px\"><td>"+array2[0]+"</td>"+"<td>"+array2[1]+"</td>"+"<td>"+array2[2]+"</td>"+"<td>"+array2[3]+"</td>"+
            "<td>"+array2[4]+"</td>"+"<td>"+array2[5]+"</td>"+"<td>"+array2[6]+"</td><tr>";
        }
        $("#result_div").html('<table class="table_solid" border="0" cellspacing="0">' + '<tr style="text-align: center; color: blue">' + ' <td>高校编号</td>' +
            '            <td width="180">高校名称</td>\n' +
            '            <td>高校所在地</td>\n' +
            '            <td>所属批次</td>\n' +
            '            <td>上一年学校录取分</td>\n' +
            '            <td>专业名称</td>\n' +
            '            <td>上一年专业录取分</td>\n' +
            '        </tr>\n' +str+
            '    </table>\n');
    });
}
$(function(){
    $(".table_solid").tableUI();
})
function load_school() {
    $("#school").empty();
    $("#school").append("<option value='0'>- - 请选择院校 - -</option>");
    var batch_id = $("#batch").val();
    $.post("/find_by_batch",{"batch_id":batch_id},function (str) {
        if(str != null){
            var array = str.split("|");
            for(var i=0;i<array.length-1;i++){
                var array2 = array[i].split("^");
                $("#school").append("<option value='"+array2[0]+"'>"+array2[1]+"</option>");
            }
        }
    });
}
function load_major() {
    $("#major").empty();
    $("#major").append("<option value='0'>- - 请选择专业 - -</option>");
    var sch_id = $("#school").val();
    $.post("/major_search",{"sch_id":sch_id},function (str) {
        if(str != null){
            var array = str.split("|");
            for(var i=0;i<array.length-1;i++){
                var array2 = array[i].split("^");
                $("#major").append("<option value='"+array2[0]+"'>"+array2[1]+"</option>");
            }
        }
    });
}
$("#batch").change(function () {
    load_school();//重新加载高校
    load_major();//重新加载专业
});
$("#school").change(function () {
    load_major();//重新加载专业
});

</script>
</html>